package com;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.DBManipulation;

/**
 * Servlet implementation class EditDebitNoteServlet
 */
public class EditDebitNoteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EditDebitNoteServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		try 
		{ 	
			DebitNoteBean dnb = new DebitNoteBean(); 
			
			dnb.setPurchaseOrderNumber(request.getParameter("dbordernum"));
			dnb.setPurchaseInvoiceNumber(request.getParameter("dbinvoice"));
			dnb.setPurchaseDate(request.getParameter("dbdate"));
			dnb.setSupplierName(request.getParameter("suppliername"));
			dnb.setSupplierCode(request.getParameter("suppliercode"));
			dnb.setProductName(request.getParameter("stockname"));
			dnb.setPurchaseProdQuantity(Integer.parseInt(request.getParameter("dbproductquantity")));
			dnb.setPurchaseProdRate(Double.parseDouble(request.getParameter("dbproductrate")));
			dnb.setPurchaseNetAmount(Double.parseDouble(request.getParameter("dbnetamount")));
			dnb.setPurchaseTaxCategory(Double.parseDouble(request.getParameter("dbtaxcat")));
			dnb.setPurchaseTaxAmount(Double.parseDouble(request.getParameter("dbtaxamount")));
			dnb.setPurchaseTransport(Double.parseDouble(request.getParameter("dbtransport")));
			dnb.setPurchaseOtherCosts(Double.parseDouble(request.getParameter("dbothercosts")));
			dnb.setPurchaseTotalAmount(Double.parseDouble(request.getParameter("dbtotalamount")));
			dnb.setPurchaseCreditLimit(Integer.parseInt(request.getParameter("dbcredlimit")));
			dnb.setPurchaseRejectionReason(request.getParameter("dbrejectionreason"));
			

			DBManipulation dbc= new DBManipulation();
			dbc.updateDebitNote(dnb);
		}
		catch (Throwable theException) 
		{ 
			System.out.println(theException); 
			} 
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
